package x_yeyue.obj;

import x_yeyue.GameWin;
import x_yeyue.utils.GameUtils;

import java.awt.*;

public class Enemy2BulletObj extends GameObj{
    public Enemy2BulletObj() {
    }

    public Enemy2BulletObj(Image img, int x, int y, double speed) {
        super(img, x, y, speed);
    }

    public Enemy2BulletObj(int x, int y) {
        super(x, y);
    }

    public Enemy2BulletObj(Image img, int width, int height, int x, int y, double speed, GameWin frame) {
        super(img, width, height, x, y, speed, frame);
    }

    @Override
    public void paintSelf(Graphics g) {
        super.paintSelf(g);
        y += speed;
        for (ShellObj shellObj : GameUtils.shellObjList) {
            if(this.getRec().intersects(shellObj.getRec())){
                // 碰撞之后出现爆炸动画
                ExplodeObj explodeObj = new ExplodeObj(x, y);
                GameUtils.explodeObjsList.add(explodeObj);
                GameUtils.removeList.add(explodeObj);

                this.x = -100;
                this.y = -100;
                GameUtils.removeList.add(shellObj);
                GameUtils.removeList.add(this);
//                GameWin.score += 3;
            }
        }
    }

    @Override
    public Rectangle getRec() {
        return super.getRec();
    }
}
